<template>
  <div>
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item> <i class="el-icon-lx-cascades"></i> 监控中心 </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="container">
      <el-tabs v-model="activeName" tab-position="left" type="border-card" @tab-click="tabClick">
        <el-tab-pane v-for="(item, i) in leftListData" :key="String(item.id)" :label="item.name" :name="String(item.id)">
          <tab-riaght v-if="String(item.id) === activeName" :keyWord.sync='keyWord' :loadingfenFormLoad='loadingfenFormLoad'
                      :fenFormDataArr="fenFormDataArr" :threeLevelsbool="threeLevelsbool" :activeName="activeName" :addNum="addNum" @getRen='getRen'
                      :optionVal="optionVal" :haiOptionVal="haiOptionVal"></tab-riaght>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>
</template>

<script>
import { InternationalWatersTeamUserAjax, RolePermissionsQX, WaitCustomerAddDay, InternationalWatersSetUserData, customerFormSeleVal, customerFormSeleHaiVal } from '../../../api/index';
import TabRiaght from './DealTemplate/TabRiaght';
export default {
  data() {
    return {
      activeName: '',
      valId: '',
      leftListData: [],
      addNum: {
        dayNum: 0,
        monthNum: 0,
      },

      fenFormDataArr: [],
      keyWord: '',
      loadingfenFormLoad: true,
      optionVal: [],
      haiOptionVal: [],

      threeLevelsbool: {
        hui: false,
        fen: false,
      }
    };
  },
  components: {
    'tab-riaght': TabRiaght
  },
  created() {
    this.leftList();
    this.threeLevels();
    this.getRen();
    this.selectVal();
    this.selectHaiVal();
  },
  watch: {
    $route: 'leftList',
    activeName(n, m) {
      // console.log(this.activeName)
    }
  },
  methods: {
    //left 人员
    leftList() {
      InternationalWatersTeamUserAjax().then((res) => {
        if (res.code === 0) {
          this.leftListData = res.userList;
          this.activeName = String(res.userList[0].id);
          this.addDayMon(res.userList[0].id);
        } else {
          this.$message(res.msg);
        }
      });
    },
    tabClick(msg) {
      this.addDayMon(msg.name);
    },
    //新增记录展示
    addDayMon(id) {
      WaitCustomerAddDay({ userId: id }).then((res) => {
        if (res.code === 0) {
          this.$set(this.addNum, "dayNum", res.todayNum);
          this.$set(this.addNum, "monthNum", res.monthNum);
        } else {
          this.$message(res.msg);
        }
      });
    },
    //获取人员配置
    getRen() {
      // DataStreamPeiInit
      InternationalWatersSetUserData({ keyWord: this.keyWord }).then((res) => {
        this.loadingfenFormLoad = false;
        if (res.code === 0) {
          this.fenFormDataArr = res.userList;
        } else {
          this.$message(res.msg);
        }
      });
    },
    //获取下拉数据
    selectVal() {
      customerFormSeleVal().then((res) => {
        if (res.code === 0) {
          this.optionVal = res.fromList;
        } else {
          this.$message(res.msg);
        }
      });
    },
    //获取公海下拉数据
    selectHaiVal() {
      customerFormSeleHaiVal().then((res) => {
        if (res.code === 0) {
          this.haiOptionVal = res.teamSeasList;
        } else {
          this.$message(res.msg);
        }
      });
    },
    //三级权限
    threeLevels() {
      let parentRouth = this.$route.path.replace('/', '');
      RolePermissionsQX({ urlName: parentRouth }).then((res) => {
        if (res.code === 0) {
          res.buttons.forEach((item, i) => {
            switch (item.name) {
              case '回收客户':
                this.threeLevelsbool.hui = item.pageIsShow;
                break;
              case '分配':
                this.threeLevelsbool.fen = item.pageIsShow;
                break;
            }
          });
        } else {
          this.$message(res.msg);
        }
      });
    }
  }
};
</script>

<style scoped>
</style>